<?php

if (!defined('IN_ADMIN')) {
    exit('Access Denied');
}

$mpurl = 'admin.php?ac=inform';
$list = array();
if ($_GET ['op'] == "detail") {
    //
    //
} else if ($_GET ['op'] == "chain") {
    // 封禁&解禁
    $uid = intval($_GET ['uid']);
    $status = intval($_GET ['status']);
    $forbid = intval($_GET ['forbid']);

    $param = array(
        'do' => 'chainUser',
        'format' => 'json',
        'uid' => $uid,
        'status' => $status,
        'forbidDevice' => $forbid
    );

    $content = get_api_content($_SC ['apiurl'], $param);
    $content = json_decode($content);
    if ($content->resultData == 1) {
        $msg = "操作成功!";
        cpmessage($msg);
    }
    $msg = "操作失败，请重试一次!";
    if ($content->errorNo) {
        $msg .= "errorNo:" . $content->errorNo;
    }
    cpmessage($msg);
} else {
    // 列表
    $start = intval($_GET ['start']);
    // 参数过滤解析
    $perpage = intval($_GET ['perpage']) > 0 ? intval($_GET ['perpage']) : 20;

    // 搜索条件
    $intkeys = array(
        'uid'
    );
    $strkeys = array(
        'nickname',
        'account',
        'email',
        'deviceSN'
    );
    $results = getparam($intkeys, $strkeys);
    $mpurl .= '&' . implode('&', $results ['urls']);

    // 构建api请求url与参数数组
    $param = array(
        'do' => 'getInformList',
        'format' => 'json',
        'start' => $start,
        'length' => $perpage
    );
    $param = array_merge($param, $results ['param']);
    // var_dump ( $param );
    // die ();
    // 读取api数据
    $content = get_api_content($_SC ['apiurl'], $param);
    $content = json_decode($content);
    if ($content->resultData) {
        $list = object_to_array($content->resultData);
    }

    // page
    $pageurl = multi($start, $perpage, $mpurl);
    $nextpurl = $pageurl ['next'];
    $prevpurl = $pageurl ['prev'];
    $mpurl = $pageurl ['urls'];
    $firstpurl = $pageurl ['first'];

    $perpages = array(
        $perpage => ' selected'
    );
}
